﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace MvcControlsToolkit
{
    public abstract class Container: Control
    {
        public Container(string name):base(name){}

        internal ContentType ContentType { get; set; }
        /// <summary>
        /// If ContentType is set to RemoteAction, defines the remote action relative url
        /// </summary>
        public string Action { get; set; }

        /// <summary>
        /// If ContentType is set to Static, defines the HTML content
        /// </summary>
        internal string HTMLContent { get; set; }

        /* If ContentType is set to PartialView, defines the PartialView rendering details */
        internal string PartialViewName { get; set; }
        internal object PartialViewModel { get; set; }
        internal ViewDataDictionary PartialViewData { get; set; }

        public virtual Container SetContent(ContentType contentType, string name, object objectModel = null, ViewDataDictionary viewData = null)
        {
            
            this.ContentType = contentType;

            switch (contentType)
            {
                case ContentType.Static:
                    this.HTMLContent = name;
                    break;
                case ContentType.PartialView:
                    this.PartialViewName = name;
                    this.PartialViewModel = objectModel;
                    this.PartialViewData = viewData;
                    break;
                case ContentType.RemoteAction:
                    Action = name;
                    break;
            }

            return this;        
        }
    }
}
